<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">















 
 
 
 
 
 
 
  
  


<html>
  <head>
    <script type="text/javascript" language="JavaScript">
    ORIGINAL_PAGE_PATH = "/appengine/docs/python/datastore/propertyclass.html";
    </script>
    
    
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>The Property Class - Google App Engine - Google Code</title>
<script type="text/javascript"><!--
(function(){function a(){this.t={};this.tick=function(c){this.t[c]=(new Date).getTime()};this.tick("start")}var b=new a;window.jstiming={Timer:a,load:b};if(window.external&&window.external.pageT)window.jstiming.pt=window.external.pageT;})();

var _tocPath_ = '/appengine/docs/_toc.ezt';
var codesite_token = null;
//--></script>
<link href="../../../../css/codesite.pack.04102009.css" type="text/css" rel="stylesheet"></link>
<script src="../../../../js/codesite_head.pack.04102009.js" type="text/javascript"></script>
<script type="text/javascript">CODESITE_CSITimer['load'].tick('bhs');</script>
<link rel="search" type="application/opensearchdescription+xml" title="Google Code" href="http://code.google.com/osd.xml" />

<!--[if IE]><link rel="stylesheet" type="text/css" href="../../../../css/iehacks.css" /><![endif]-->

    <link href="../../../../css/semantic_headers.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/local_extensions.css" rel="stylesheet" type="text/css" />
  </head>

  <body class="gc-documentation">

    
    
    
</a>

<div id="gb">
 <span>
  
    <a id="lang-dropdown" class="dropdown" href="http://code.google.com" onclick="return false;"><img class="globeicon" src="../../../../images/globe2_small.png"/><span>English</span></a>
  
 </span>
</div>

<div class="gbh" style="left: 0pt;"></div>
<div class="gbh" style="right: 0pt;"></div>


<style type="text/css">
  #gc-topnav h1 {
    padding: 0 0 0 6px;
  }
</style>


<div id="gc-container">
<a name="top"></a>
<div id="skipto">
  <a href="#gc-pagecontent">Skip to page content</a>
  <a href="#gc-toc">Skip to main navigation</a>
</div>

<div id="gc-header">
  <div id="logo"><a href="http://code.google.com">
  
  
     <img src="../../../../images/cleardot.gif" height="1px" width="1px" alt="Google Code Home Page" id="gc-logo-img"/>
  
  
  </a></div>
  <div id="search">
    <div id="searchForm" class="searchForm">
      <form id="cse" action="http://www.google.com/cse" accept-charset="utf-8" class="gsc-search-box" onsubmit="executeGSearch(document.getElementById('gsearchInput').value); return false;">
      <noscript>
      <input type="hidden" name="cref" value="http://code.google.com/cse/googlecode-context.xml"/>
      </noscript>
        <table class="gsc-search-box" cellpadding="0" cellspacing="0">
          <tbody>
            <tr>
              <td class="gsc-input">
                <input id="gsearchInput" type="text" name="q" maxlength="2048" class="gsc-input" autocomplete="off" title="Google Code Search" style="width:345px"/>
              </td>
              <td class="gsc-search-button">
                <div id="cs-searchresults" onclick="event.cancelBubble = true;"></div>
                <input title="Search" id="gsearchButton" class="gsc-search-button" name="sa" value="Search" type="submit"/>
              </td>
            </tr>
            <tr>
              <td colspan="2" class="greytext">e.g. "templates" or "datastore"</td>
            </tr>
          </tbody>
        </table>
      </form>
    </div> <!-- end searchForm -->
  </div> <!-- end search -->
</div> <!-- end gc-header -->


<div id="codesiteContent">

<a name="gc-topnav-anchor"></a>
<div id="gc-topnav">
  <h1>Google App Engine</h1>
  <ul id="docs" class="gc-topnav-tabs">

    <li id="home_link">
      <a href="../../../index.html" title="Google App Engine home page">Home</a>
    </li>
  
    <li id="docs_link">
      <a href="../../index.html" class="selected" title="Official Google App Engine documentation">Docs</a>
    </li>
  
    <li id="faq_link">
      <a href="../../../kb/index.html" title="Answers to frequently asked questions about Google App Engine">FAQ</a>
    </li>
  
    <li id="articles_link">
      <a href="../../../articles/index.html" title="Focused articles and tutorials for Google App Engine developers">Articles</a>
    </li>
  
    <li>
      <a href="http://googleappengine.blogspot.com/" title="Official Google App Engine blog">Blog</a>
    </li>
  
    <li>
      <a href="../../../community.html" title="Community home for Google App Engine">Community</a>
    </li>
  
    <li>
      <a href="../../../terms.html" title="Google App Engine terms of service">Terms</a>
    </li>
  
    <li>
      <a href="../../../downloads.html" title="Download Google App Engine">Download</a>
    </li>
  

  </ul>
</div> <!-- end gc-topnav -->

    <div class="g-section g-tpl-170">

      <div class="g-unit g-first" id="gc-toc">
        <ul>
  <li><a href="../../../downloads.html">Downloads</a></li>
  <li><a href="http://code.google.com/status/appengine">System Status</a></li>
  <li><a href="http://code.google.com/p/googleappengine/issues/list">Issue Tracker</a></li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Getting Started</h2>
    <ul>
      <li><a href="../../whatisgoogleappengine.html">What Is Google App Engine?</a></li>
      <li><a href="../../java/gettingstarted/index.html">Java</a>
        <ul>
              <li><a href="../../java/gettingstarted/introduction.html">Introduction</a></li>
    <li><a href="../../java/gettingstarted/installing.html">Installing the Java SDK</a></li>
    <li><a href="../../java/gettingstarted/creating.html">Creating a Project</a></li>
    <li><a href="../../java/gettingstarted/usingusers.html">Using the Users Service</a></li>
    <li><a href="../../java/gettingstarted/usingjsps.html">Using JSPs</a></li>
    <li><a href="../../java/gettingstarted/usingdatastore.html">Using the Datastore with JDO</a></li>
    <li><a href="../../java/gettingstarted/staticfiles.html">Using Static Files</a></li>
    <li><a href="../../java/gettingstarted/uploading.html">Uploading Your Application</a></li>

        </ul>
      </li>
      <li><a href="../gettingstarted/index.html">Python</a>
        <ul>
            <li><a href="../gettingstarted/introduction.html">Introduction</a></li>
  <li><a href="../gettingstarted/devenvironment.html">The Development Environment</a></li>
  <li><a href="../gettingstarted/helloworld.html">Hello, World!</a></li>
  <li><a href="../gettingstarted/usingwebapp.html">Using the webapp Framework</a></li>
  <li><a href="../gettingstarted/usingusers.html">Using the Users Service</a></li>
  <li><a href="../gettingstarted/handlingforms.html">Handling Forms With webapp</a></li>
  <li><a href="../gettingstarted/usingdatastore.html">Using the Datastore</a></li>
  <li><a href="../gettingstarted/templates.html">Using Templates</a></li>
  <li><a href="../gettingstarted/staticfiles.html">Using Static Files</a></li>
  <li><a href="../gettingstarted/uploading.html">Uploading Your Application</a></li>

        </ul>
      </li>
    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Java <sup class="new">Early Look</sup></h2>
    <ul>
          <li><a href="../../java/overview.html">Overview</a></li>
    <li><a href="../../java/runtime.html">Servlet Environment</a></li>
    <li><a href="../../java/datastore/index.html">Storing Data</a>
      <ul>
            <li><a href="../../java/datastore/overview.html">Overview</a></li>
    <li><a href="../../java/datastore/usingjdo.html">Using JDO</a></li>
    <li><a href="../../java/datastore/dataclasses.html">Defining Data Classes</a></li>
    <li><a href="../../java/datastore/creatinggettinganddeletingdata.html">Creating, Getting and Deleting Data</a></li>
    <li><a href="../../java/datastore/queriesandindexes.html">Queries and Indexes</a></li>
    <li><a href="../../java/datastore/transactions.html">Transactions</a></li>
    <li><a href="../../java/datastore/relationships.html">Relationships</a></li>
    <li><a href="../../java/datastore/usingjpa.html">Using JPA</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/datastore/package-summary.html">Low-level API</a></li>

      </ul>
    </li>
    <li><a href="../../java/apis.html">Services</a>
      <ul>
        <li><a href="../../java/memcache/index.html">Memcache</a>
          <ul>
                <li><a href="../../java/memcache/overview.html">Overview</a></li>
    <li><a href="../../java/memcache/usingjcache.html">Using JCache</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/memcache/package-summary.html">Low-level API</a></li>

          </ul>
        </li>
        <li><a href="../../java/urlfetch/index.html">URL Fetch</a>
          <ul>
                <li><a href="../../java/urlfetch/overview.html">Overview</a></li>
    <li><a href="../../java/urlfetch/usingjavanet.html">Using java.net</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/urlfetch/package-summary.html">Low-level API</a></li>

          </ul>
        </li>
        <li><a href="../../java/mail/index.html">Mail</a>
          <ul>
                <li><a href="../../java/mail/overview.html">Overview</a></li>
    <li><a href="../../java/mail/usingjavamail.html">Using JavaMail</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/mail/package-summary.html">Low-level API</a></li>

          </ul>
        </li>
        <li><a href="../../java/images/index.html">Images</a>
          <ul>
                <li><a href="../../java/images/overview.html">Overview</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/images/package-summary.html">API Reference</a></li>

          </ul>
        </li>
        <li><a href="../../java/users/index.html">Google Accounts</a>
          <ul>
                <li><a href="../../java/users/overview.html">Overview</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/users/package-summary.html">API Reference</a></li>

          </ul>
        </li>
      </ul>
    </li>
    <li><a href="../../java/javadoc/index.html">Javadoc Reference</a></li>
    <li><a href="../../java/jrewhitelist.html">JRE Class White List</a></li>
    <li><a href="../../java/config/index.html">Configuration</a>
      <ul>
            <li><a href="../../java/config/webxml.html">Deployment Descriptor</a></li>
    <li><a href="../../java/config/appconfig.html">App Config</a></li>
    <li><a href="../../java/config/indexconfig.html">Index Config</a></li>
    <li><a href="../../java/config/cron.html">Scheduled Tasks</a></li>

      </ul>
    </li>
    <li><a href="../../java/tools/index.html">Tools</a>
      <ul>
            <li><a href="../../java/tools/devserver.html">Development Server</a></li>
    <li><a href="../../java/tools/uploadinganapp.html">Uploading and Managing</a></li>
    <li><a href="../../java/tools/eclipse.html">Google Plugin for Eclipse</a></li>
    <li><a href="../../java/tools/ant.html">Using Apache Ant</a></li>

      </ul>
    </li>
    <li><a href="../../java/howto/index.html">How-To</a>
      <ul>
              <li><a href="../../java/howto/unittesting.html">Unit Testing</a></li>

      </ul>
    </li>

    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Python</h2>
    <ul>
          <li><a href="../overview.html">Overview</a></li>
    <li><a href="../runtime.html">CGI Environment</a></li>
    <li><a href="index.html">Storing Data</a>
      <ul>
             <li><a href="overview.html">Overview</a></li>
     <li><a href="entitiesandmodels.html">Entities and Models</a></li>
     <li><a href="creatinggettinganddeletingdata.html">Creating, Getting and Deleting Data</a></li>
     <li><a href="keysandentitygroups.html">Keys and Entity Groups</a></li>
     <li><a href="queriesandindexes.html">Queries and Indexes</a></li>
     <li><a href="transactions.html">Transactions</a></li>
     <li><a href="typesandpropertyclasses.html">Types and Property Classes</a></li>
     <li><a href="gqlreference.html">GQL Reference</a></li>

     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="modelclass.html">Model</a></li>
         <li><a href="expandoclass.html">Expando</a></li>
         <li><a href="polymodelclass.html">PolyModel</a></li>
         <li><a href="propertyclass.html">Property</a></li>
         <li><a href="queryclass.html">Query</a></li>
         <li><a href="gqlqueryclass.html">GqlQuery</a></li>
         <li><a href="keyclass.html">Key</a></li>
         <li><a href="functions.html">Functions</a></li>
         <li><a href="exceptions.html">Exceptions</a></li>
       </ul>
     </li>

      </ul>
    </li>
    <li><a href="../apis.html">Services</a>
      <ul>
        <li><a href="../memcache/index.html">Memcache</a>
          <ul>
                 <li><a href="../memcache/overview.html">Overview</a></li>
      <li><a href="../memcache/usingmemcache.html">Using Memcache</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../memcache/clientclass.html">Client</a></li>
         <li><a href="../memcache/functions.html">Functions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../urlfetch/index.html">URL Fetch</a>
          <ul>
                 <li><a href="../urlfetch/overview.html">Overview</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../urlfetch/fetchfunction.html">The fetch Function</a></li>
         <li><a href="../urlfetch/responseobjects.html">Response Objects</a></li>
         <li><a href="../urlfetch/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../mail/index.html">Mail</a>
          <ul>
                 <li><a href="../mail/overview.html">Overview</a></li>
     <li><a href="../mail/sendingmail.html">Sending Mail</a></li>
     <li><a href="../mail/attachments.html">Attachments</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../mail/emailmessageclass.html">EmailMessage</a></li>
         <li><a href="../mail/emailmessagefields.html">Message Fields</a></li>
         <li><a href="../mail/functions.html">Functions</a></li>
         <li><a href="../mail/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../images/index.html">Images</a>
          <ul>
                 <li><a href="../images/overview.html">Overview</a></li>
     <li><a href="../images/installingPIL.html">Installing PIL</a></li>
     <li><a href="../images/usingimages.html">Using the Images API</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../images/imageclass.html">Image</a></li>
         <li><a href="../images/functions.html">Functions</a></li>
         <li><a href="../images/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../users/index.html">Google Accounts</a>
          <ul>
                 <li><a href="../users/overview.html">Overview</a></li>
     <li><a href="../users/userobjects.html">User Objects</a></li>
     <li><a href="../users/loginurls.html">Login URLs</a></li>
     <li><a href="../users/adminusers.html">Admin Users</a></li>

     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../users/userclass.html">User</a></li>
         <li><a href="../users/functions.html">Functions</a></li>
         <li><a href="../users/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
      </ul>
    </li>
    <li><a href="../config/index.html">Configuration</a>
      <ul>
            <li><a href="../config/appconfig.html">App Config</a></li>
    <li><a href="../config/indexconfig.html">Index Config</a></li>
    <li><a href="../config/cron.html">Scheduled Tasks</a></li>

      </ul>
    </li>
    <li><a href="../tools/index.html">Tools</a>
      <ul>
            <li><a href="../tools/devserver.html">Development Server</a></li>
    <li><a href="../tools/uploadinganapp.html">Uploading and Managing</a></li>
    <li><a href="../tools/uploadingdata.html">Uploading Data</a></li>
    <li><a href="../tools/webapp/index.html">webapp Framework</a>
      <ul>
             <li><a href="../tools/webapp/overview.html">Overview</a></li>
     <li><a href="../tools/webapp/running.html">Running the Application</a></li>
     <li><a href="../tools/webapp/requesthandlers.html">Request Handlers</a></li>
     <li><a href="../tools/webapp/requestdata.html">Request Data</a></li>
     <li><a href="../tools/webapp/buildingtheresponse.html">Building the Response</a></li>
     <li><a href="../tools/webapp/redirects.html">Redirects, Headers and Status Codes</a></li>
     

     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../tools/webapp/requestclass.html">Request</a></li>
         <li><a href="../tools/webapp/responseclass.html">Response</a></li>
         <li><a href="../tools/webapp/requesthandlerclass.html">RequestHandler</a></li>
         <li><a href="../tools/webapp/wsgiapplicationclass.html">WSGIApplication</a></li>
         <li><a href="../tools/webapp/utilmodule.html">Utility Functions</a></li>
         
       </ul>
     </li>

      </ul>
    </li>
    <li><a href="../tools/libraries.html">Third-party Libraries</a></li>

      </ul>
    </li>
    <li><a href="../howto/index.html">How-To</a>
      <ul>
              <li><a href="../howto/usinggdataservices.html">Google Data Services</a></li>

      </ul>
    </li>

    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Managing Your App</h2>
    <ul>
      <li><a href="../../theadminconsole.html">The Admin Console</a></li>
      <li><a href="../../quotas.html">Quotas</a></li>
      <li><a href="../../billing.html">Billing</a></li>
    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Resources</h2>
    <ul>
      <li><a href="../../../kb/index.html">FAQ</a></li>
      <li><a href="../../../articles/index.html">Articles</a></li>
      <li><a href="http://appengine-cookbook.appspot.com/">Cookbook</a></li>
      <li><a href="http://appgallery.appspot.com/">App Gallery</a></li>
      <li><a href="http://code.google.com/p/googleappengine/">SDK Code</a></li>
      <li><a href="http://code.google.com/p/google-app-engine-samples/">Sample Apps Code</a></li>
      <li><a href="../../../community.html">Discussion Groups</a></li>
    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><a href="../../roadmap.html">Product Roadmap</a></li>
  <li><a href="http://code.google.com/p/googleappengine/wiki/SdkReleaseNotes">Release Notes</a></li>
  <li><a href="../../revision_history.html">Revision History</a></li>
</ul>

        <a class="hidden" href="#gc-topnav-anchor">More Google App Engine resource links</a>
      </div>

      <div class="g-unit" id="gc-pagecontent">
        <h1 class="page_title">The Property Class</h1>



<p>The Property class is the superclass of property definitions for data models.  A Property class defines the type of a property's value, how values are validated, and how values are stored in the datastore.</p>

<p><code>Property</code> is provided by the <code>google.appengine.ext.db</code> module.</p>

<ul>
  <li><a href="#Introduction">Introduction</a></li>
  <li><a href="#Property">Property()</a></li>
  <li>Class attributes:
    <ul>
      <li><a href="#Property_data_type">Property.data_type</a></li>
    </ul>
  </li>
  <li>Instance methods:
    <ul>
      <li><a href="#Property_default_value">default_value()</a></li>
      <li><a href="#Property_validate">validate()</a></li>
      <li><a href="#Property_empty">empty()</a></li>
      <li><a href="#Property_get_value_for_datastore">get_value_for_datastore()</a></li>
      <li><a href="#Property_make_value_from_datastore">make_value_from_datastore()</a></li>
    </ul>
  </li>
</ul>


<h2 id="Introduction">Introduction</h2>

<p>A property class describes the value type, default value, validation logic and other features of a property of a <a href="modelclass.html">Model</a>.  Each property class is a subclass of the Property class.  The datastore API includes property classes for each of the datastore value types, and several others that provide additional features on top of the datastore types.  See <a href="typesandpropertyclasses.html">Types and Property Classes</a>.</p>

<p>A property class can accept configuration from arguments passed to the constructor.  The base class constructor supports several arguments that are typically supported in all property classes, including all those provided in the datastore API.  Such configuration can include a default value, whether or not an explicit value is required, a list of acceptable values, and custom validation logic.  See the documentation for a specific property type for more information on configuring the property.<p>

<p>A property class defines the model for a datastore property.  It does not contain the property value for a model instance.  Instances of the Property class belong to the Model class, not instances of the class.  In Python terms, property class instances are "descriptors" that customize how attributes of Model instances behave.  See <a href="http://docs.python.org/ref/attribute-access.html">the Python documentation</a> for more information about descriptors.</p>


<h2>Constructor</h2>

<p>The constructor of the Property base class is defined as follows:</p>

<dl class="apireference">
  <dt id="Property"><span class="type">class</span>&nbsp;<span class="itemname">Property</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">name</span>=<span class="argdefault">None</span>, <span class="argname">default</span>=<span class="argdefault">None</span>, <span class="argname">required</span>=<span class="argdefault">False</span>, <span class="argname">validator</span>=<span class="argdefault">None</span>, <span class="argname">choices</span>=<span class="argdefault">None</span>, <span class="argname">indexed</span>=<span class="argdefault">True</span>)</dt>
  <dd>
    <p>The superclass of model property definitions.</p>

    <p>Arguments:</p>

    <dl>
      <dt><span class="argname">verbose_name</span></dt>
      <dd>A user-friendly name of the property.  This must always be the first argument to a property constructor.  The <code>djangoforms</code> library uses this to make labels for form fields, and others can use it for a similar purpose.</dd>

      <dt><span class="argname">name</span></dt>
      <dd>The storage name for the property, used in queries.  This defaults to the attribute name used for the property.  Because model classes have attributes other than properties (which cannot be used for properties), a property can use <span class="argname">name</span> to use a reserved attribute name as the property name in the datastore, and use a different name for the property attribute.  See <a href="modelclass.html#Disallowed_Property_Names">Disallowed Property Names</a> for more information.</dd>

      <dt><span class="argname">default</span></dt>
      <dd>
        <p>A default value for the property.  If the property value is never given a value, or is given a value of <code>None</code>, then the value is considered to be the default value.</p>
        <p class="note"><b>Note:</b> Model class definitions are cached along with the rest of the application code.  This includes caching default values for properties.  Do not set a <span class="argname">default</span> in the model definition with data specific to the request (such as <a href="../users/functions.html#get_current_user">users.get_current_user()</a>).  Instead, define an <code>__init__()</code> method for the <a href="modelclass.html">Model</a> class that initializes the property values.</p>
      </dd>

      <dt><span class="argname">required</span></dt>
      <dd>
        <p>If <code>True</code>, the property cannot have a value of <code>None</code>.  A model instance must initialize all required properties in its constructor so that the instance is not created with missing values.  An attempt to create an instance without initializing a required property, or an attempt to assign <code>None</code> to a required property, raises a <a href="exceptions.html#BadValueError">BadValueError</a>.</p>
        <p>A property that is both required and has a default value uses the default value if one is not given in the constructor.  However, the property cannot be assigned a value of <code>None</code>, and there is no automatic way to restore the default value after another value has been assigned.  You can always access the property's <code>default</code> attribute to get this value and assign it explicitly.</p>
      </dd>

      <dt><span class="argname">validator</span></dt>
      <dd>A function that should be called to validate the property's value when the value is assigned.  The function takes the value as its only argument, and raises an exception if the value is invalid.  The given validator is called after other validation has taken place, such as the check that a required property has a value.</dd>

      <dt><span class="argname">choices</span></dt>
      <dd>A list of acceptable values for the property.  If set, the property cannot be assigned a value not in the list.  As with <span class="argname">required</span> and other validation, a model instance must initialize all properties with choices so that the instance is not created with invalid values.  If <span class="argname">choices</span> is <code>None</code>, then all values that otherwise pass validation are acceptable.</dd>

      <dt><span class="argname">indexed</span></dt>
      <dd>
        <p>Whether this property should be included in the built-in and developer-defined <a href="queriesandindexes.html">indexes</a>. If <code>False</code>, entities written to the datastore will never be returned by queries that sort or filter on this property, similar to <a href="typesandpropertyclasses.html#Blob">Blob</a> and <a href="typesandpropertyclasses.html#Text">Text</a> properties.</p>
        <p class="note"><b>Note:</b> Every indexed property adds a small amount of overhead, CPU cost, and latency to <code>put()</code> and <code>delete()</code> calls. If you'll never need to filter or sort on a property, consider using <code>indexed=False</code> to avoid that overhead. Be careful, though! If you decide later that you want the property indexed after all, changing it back to <code>indexed=True</code> will only affect writes from that point onward. Entities that were originally written with <code>indexed=False</code> will not be re-indexed.</p>
      </dd>
    </dl>
  </dd>
</dl>


<h2>Class Attributes</h2>

<p>Subclasses of the Property class define the following class attribute:</p>

<dl class="apireference">
  <dt id="Property_data_type"><code>data_type</code></dt>
  <dd>The Python data type or class the property accepts as a Python-native value.</dd>
</dl>


<h2>Instance Methods</h2>

<p>Instances of Property classes have the following methods:</p>

<dl class="apireference">

  <dt id="Property_default_value"><span class="itemname">default_value</span>()</dt>
  <dd>
    <p>Returns the default value for the property.  The base implementation uses the value of the <span class="argname">default</span> argument passed to the constructor.  A property class could override this to provide special default value behavior, such as <a href="typesandpropertyclasses.html#DateTimeProperty">DateTimeProperty</a>'s auto-now feature.</p>
  </dd>

  <dt id="Property_validate"><span class="itemname">validate</span>(<span class="argname">value</span>)</dt>
  <dd>
    <p>The complete validation routine for the property.  If <span class="argname">value</span> is valid, it returns the value, either unchanged or adapted to the required type.  Otherwise it raises an appropriate exception.</p>
    <p>The base implementation checks that <span class="argname">value</span> is not <code>None</code> if required (the <span class="argname">required</span> argument to the base Property constructor), the value is one of the valid choices if the property was configured with choices (the <span class="argname">choices</span> argument), and the value passes the custom validator if any (the <span class="argname">validator</span> argument).</p>
    <p>The validation routine is called when a model using the property type is instantiated (with default or initialized values), and when a property of the type is assigned a value.  The routine should not have side effects.</p>
  </dd>

  <dt id="Property_empty"><span class="itemname">empty</span>(<span class="argname">value</span>)</dt>
  <dd>
    <p>Returns <code>True</code> if <span class="argname">value</span> is considered an empty value for this property type.  The base implementation is equivalent to <code>not value</code>, which is sufficient for most types.  Other types, like a Boolean type, can override this method with a more appropriate test.</p>
  </dd>
  
  <dt id="Property_get_value_for_datastore"><span class="itemname">get_value_for_datastore</span>(<span class="argname">model_instance</span>)</dt>
  <dd>
    <p>Returns the value that ought to be stored in the datastore for this property in the given model instance.  The base implementation simply returns the Python-native value of the property in the model instance.  A property class can override this to use a different data type for the datastore than for the model instance, or to perform other data conversion just prior to storing the model instance.</p>
  </dd>

  <dt id="Property_make_value_from_datastore"><span class="itemname">make_value_from_datastore</span>(<span class="argname">value</span>)</dt>
  <dd>
    <p>Returns the Python-native representation for the given value from the datastore.  The base implementation simply returns the value.  A property class can override this to use a different data type for the model instance than for the datastore.</p>
  </dd>
  
</dl>



      </div><!-- end gc-pagecontent -->
   </div><!-- end gooey wrapper -->

    </div> <!-- end codesite content -->

<div id="gc-footer" dir="ltr">
  <div class="text">
    
      <div class="notice"><div id="notice" style="text-align: center; border: 1em 0em 1em 0em">
  Except as otherwise <a
  href="http://code.google.com/policies.html#restrictions">noted</a>,
  the content of this page is licensed under the <a rel="license"
  href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
  Attribution 2.5 License</a>, and code samples are licensed under the
  <a rel="license" href="http://www.apache.org/licenses/LICENSE-2.0">Apache
  2.0 License</a>.
<!-- <rdf:RDF xmlns="http://web.resource.org/cc/" 
              xmlns:dc="http://purl.org/dc/elements/1.1/"
              xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <Work rdf:about="">
    <license rdf:resource="http://creativecommons.org/licenses/by/2.5/" />
  </Work>
  <License rdf:about="http://creativecommons.org/licenses/by/2.5/">
    <permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
    <permits rdf:resource="http://web.resource.org/cc/Distribution"/>
    <requires rdf:resource="http://web.resource.org/cc/Notice"/>
    <requires rdf:resource="http://web.resource.org/cc/Attribution"/>
    <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
  </License>
</rdf:RDF> -->
</div>
Java is a registered trademark of Sun Microsystems, Inc.</div>
    
    &copy;2009 Google -
    <a href="http://code.google.com">Code Home</a> -
    <a href="http://www.google.com/accounts/TOS">Terms of Service</a> -
    <a href="http://www.google.com/privacy.html">Privacy Policy</a> -
    <a href="http://code.google.com/more">Site Directory</a>
    <br /> <br />
    Google Code offered in:
    <a href="http://code.google.com/intl/en">English</a> -
    <a href="http://code.google.com/intl/es">Español</a> -
    <a href="http://code.google.com/intl/ja">日本語</a> -
    <a href="http://code.google.com/intl/ko">한국어</a> -
    <a href="http://code.google.com/intl/pt-BR">Português</a> -
    <a href="http://code.google.com/intl/ru">Pусский</a> -
    <a href="http://code.google.com/intl/zh-CN">中文(简体)</a> -
    <a href="http://code.google.com/intl/zh-TW">中文(繁體)</a>
  </div>
</div><!-- end gc-footer -->

</div><!-- end gc-containter -->

<script type="text/javascript">CODESITE_CSITimer['load'].tick('ats');</script>
<script src="../../../../js/codesite_tail.pack.04102009.js" type="text/javascript"></script>






  </body>
</html>


